package com.yjd.merchant.api.order;

import com.yjd.comm.base.control.MerchantBaseControl;
import com.yjd.comm.base.enums.DbWREnums;
import com.yjd.comm.settlement.model.ClearDayMerchantModel;
import com.yjd.comm.settlement.service.IClearDayMerchantService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * Created by yjd-wap on 2017/8/17.
 */

@Controller
@Scope("prototype")
@RequestMapping("/settlement/")
public class SettlementControl extends MerchantBaseControl {

    @RequestMapping(value = "dayClear", method = RequestMethod.POST)
    public void dayClear(Long id) throws Exception {
        if(id==null){
            this.errorMsg("参数错误");
            return;
        }
        ClearDayMerchantModel clearDayMerchantModel = clearDayMerchantService.getModelById(id, DbWREnums.READ);
        if(clearDayMerchantModel==null){
            this.errorMsg("结算单不存在");
            return;
        }
        clearDayMerchantService.settlement(super.getMerchantId(), id);
        this.successMsg("结算成功");
    }

    @Resource
    IClearDayMerchantService clearDayMerchantService;
}
